# -*- encoding : utf-8 -*-
class BookCategory < ActiveRecord::Base
  validates :category_name, :presence => true, :uniqueness => true
  attr_accessible :category_name
  
  def self.search(search)
    if search
      find(:all, :conditions => ['category_name LIKE ?', "%#{search}%"])
    else
      find(:all)
    end
  end
  
  def self.getBookCateName(id)
    bookcate = BookCategory.find(id)
    return bookcate.category_name
  end
  
  has_many :books

end
